home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / MENU-DD.DMO < prev    next >
Text File  |  1996-07-04  |  17KB  |  309 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   MENU-DD .DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16.  
  17. ****************************************************************************
  18. ** ** ** ** ** ** ** ** **  GENERAL CHIT-CHAT  ** ** ** ** ** ** ** ** ** **
  19. ****************************************************************************
  20.  
  21. This menu system can easily handle a whole program or a simple little pop-up
  22. event/box.  Getting all the data DIMed and set just right can be a real pain
  23. but there is just no way to make it much easier and still keep all the power
  24. that is available. The best deal would be to use this file as a test program
  25. for your data and once it's correct transfer it into your program or drop it
  26. all into a file.
  27.  
  28. Five arrays are used to  import data into the  menu and they  are discussed
  29. below. In addition there are two strings that control the "look" and "feel"
  30. of the menu and provide your program with many possibilities, one of which,
  31. should meet any requirement(s) you need.
  32.  
  33. By changing the border type, centering, wrap, and auto-open values you can
  34. create your own best set-up. These, and other values, are carried into the
  35. menu by a single string.
  36.  
  37. TYPE TempTYPE           '┌─────────────────────────
  38.   BarRow   AS BYTE      '│ row # for bar items
  39.   BarCol   AS BYTE      '│ starting column of bar items
  40.   BarCols  AS BYTE      '│ # of columns for bar items
  41.   Center   AS BYTE      '│ >0 center bar items on row  =0 left justify
  42.   BrdrOn   AS BYTE      '│ border style 0 = none, 1 = underline line, 2 = box
  43.   AutoOpen AS BYTE      '│ automatically open DD boxes when BAR item is hot
  44.   WrapOn   AS BYTE      '│ wrap cursor selections if > last goto first, etc.
  45.   ShdoOn   AS BYTE      '│ shadow effect for DD boxes SEE: DrawTShadow
  46.   Sattr    AS BYTE      '│ if .ShdoOn what attribute to use
  47. END TYPE                '└────────────────────────────────────────────────
  48.  
  49. DIM tDDsetup AS TempTYPE
  50.  
  51. M$(0) = tDDsetup + "[ tMain Menup ]"
  52.  
  53. BYTE #1 Top row for BAR MENU
  54.         If BYTE #7 = 2 then this row would be the top of the box
  55.                             else the actual BAR MENU would reside here
  56.  
  57. BYTE #2 Left most column for BAR MENU
  58.  
  59. BYTE #3 Total number of columns for BAR MENU
  60.  
  61. BYTE #4 Center BarMenu Items?
  62.          defines how the BAR MENU items will be printed
  63.          IF Center? > 0 then it will appear like PB's menu
  64.          IF Center? = 0 then it would look like:
  65.          [  File  Edit  Search  Run  Compile  Options  Debug              ]
  66.            where the items fill in from the left like GUI menus
  67.  
  68. BYTE #5 Bar Menu border style
  69.         defines how many rows are used for the BAR MENU
  70.           0 = like PB's menu
  71.           1 = a single line "──────────" under the items
  72.               this one is good for pop-up boxes, etc.
  73.           2 = a full box around the menu ( like old TurboBasic's )
  74.               in this case you can also send a "TITLE" that will be printed
  75.               top row, center
  76.               Which ever you choose the dropdown boxes will have a simple
  77.               box around them and the action is automatic so you don't need
  78.               to send any further boxing commands except for color attrs.
  79.               BYTEs #10-> Title for BarMenu box IF BYTE #6 = 2
  80.  
  81. BYTE #6 Automatically open 1st DropDown menus?
  82.         determines how the first dropdowns will open.
  83.           IF = 0 then the user will have to press <ENTER> or <DOWN>
  84.                  to open the dropdowns
  85.           IF > 0 then the first dropdowns will automatically open
  86.                  when the BAR ITEM is "HOT" and there is a dropdown
  87.                  to be had. This is PB's style.
  88.           This value also affects how <ESC> is handled
  89.  
  90. BYTE #7 Wrap selection bar?
  91.         handles the "UP", "DOWN", "LEFT", "RIGHT" keys and what happens when
  92.         the first or last item is currently selected and a further command is
  93.         incoming to go "past" the boundary.
  94.         If > 0 then it will act like PB's menu
  95.         If = 0 then the key-press will be ignored
  96.  
  97. BYTE #8 Shadow style on DropDown menu boxes:
  98.  
  99. BYTE #9 Shadow color attribute
  100.         SEE: DrawTShadow
  101.         NOTE: The menu expects the shadow to be in position #1 (lower right)
  102.               so if you use position #2 your 1st DDs will have to start in
  103.               column 3 or greater. Positions 3 and 4 will not look good as
  104.               the shadow will encroach upon the Bar Menu.
  105.  
  106. BYTEs #10 and up   SEE: BYTE #5
  107.  
  108. Why call 2 routines for each menu?
  109. MenuDD only gets the environment ready to act, and prints the BAR MENU on
  110. the screen. If the area the BAR MENU will reside over needs to be saved
  111. it will be up to you to capture it. SEE: fTBoxREAD$ This allows your
  112. program to continue on until the user elects to go to the menu, like in
  113. GUI programs. [HELP] [ABOUT] (remember?) Then, when/if the menu is actually
  114. required you simply call fMenuDD$ and instantly you're in business! You can
  115. start at any "ON" item so, if your user presses <ALT>H (for example) you
  116. could automatically jump to item #2 which would be the 1st item under the
  117. first BAR ITEM. fMenuDD$ returns the actual key-press that was used to exit
  118. the menu: <ENTER> or one of your choosing, and the selection made is carried
  119. in a parameter variable SelNo? Upon exiting, all dropdowns are closed but
  120. the BAR MENU is still up and the set-up is unchanged so it can be called
  121. again and again with no other calls to MenuDD. So, for those small programs,
  122. that can be handled by a single menu structure, you would only call MenuDD
  123. only once.
  124.  
  125. NOTE: <ENTER> is the only key that will automatically exit the menu unless
  126.               you provide other keys for this function
  127.       <ENTER> is also the only key that will return a selection value >0
  128.       <ESC>   only closes opened dropdowns and will not exit the menu unless
  129.               it has been sent as a "HOT KEY" and then only
  130.               1) if Auto-Open is "OFF" and the user is at the BAR MENU
  131.               2) if Auto-Open is "ON" and the user is in the 1st DropDown
  132.  
  133. ****************************************************************************
  134. ** ** ** ** ** ** ** ** ** ** RULES OF ENGAGEMENT ** ** ** ** ** ** ** ** **
  135. ****************************************************************************
  136.  
  137. The menu is controlled by 4 arrays:
  138.   M$()  item names  VALUES: NULL or not
  139.                       LEVEL 1 items can not be NULL
  140.                       All NULL items are replaced with a "├─────┤"
  141.                                in the pulldown menus
  142.                       ALL NULL items must be "OFF" ie: O?(x) = 0
  143.   H$()  help line   VALUES: NULL or not
  144.                       IF UBOUND(H$(1)) < UBOUND(M$(1)) THEN Help is OFF
  145.                         LINE 25 is stored and then used to Tprint the
  146.                         help string(s) to that line
  147.                       MAX Visible length of H$(x) = 78
  148.                       IF H$(x) = "" AND Help is active LINE 25 is blank
  149.   L?()  item levels  VALUES: the level of the item 1,2,3,etc
  150.                              1 = bar items
  151.                              2 = first pull-down und